class Solution:

    def decodeAtIndex(self, s: str, k: int) -> str:
        length = 0
        for i in range(len(s)):
            if s[i].isdigit():
                length *= int(s[i])
            else:
                length += 1
            if length >= k:
                break

        for j in range(i, -1, -1):
            if s[j].isdigit():
                length /= int(s[j])
                k %= length
            else:
                if k == length or k == 0:
                    return s[j]
                length -= 1

        return ""
